#include <cpp_primer.h>

using namespace std;


int main(int argc, char *argv[])
{
    if(argc != 4)
        return -1;

    ifstream ifile(argv[1]);
    ofstream odd(argv[2]), even(argv[3]);

    istream_iterator<int> iter(ifile), eof;
    ostream_iterator<int> out_odd(odd), out_even(even);

    for_each(iter, eof, [&out_odd, &out_even](const int i) {*(i & 0x1 ? out_odd : out_even)++ = i;});

    return 0;

}
